import Vue from 'vue'
const state = {
    // 存放数据
    orderList:[],
    params:{}
}

const getters={
    // 获取数据
    getOrderList:function(state){
        return  state.orderList
    }
}
const actions={
    // 异步请求
    fetchOrderList({commit,state}){
        Vue.http.post('/api/getOrderList',state.params)
        .then((res) => {
            commit('updateOrderList',res.data.list)
            // state.orderList = res.data.list
            // state.total = res.data.total
        },(err) => {

        })
    }
}
const mutations={
    // 同步更改
    updateOrderList (state,payload) {
        state.orderList = payload
    },
    updateParams (state,{key,value}) {
        state.params[key] = value
        console.log(state.params)
    }
}
export default{
    state,
    getters,
    actions,
    mutations
}